﻿<UserControl x:Class="ControleRepresentanteSync.View.Pedido.PedidoView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:Pedido="clr-namespace:ControleRepresentanteSync.View.Pedido">
    <UserControl.Resources>
        <ResourceDictionary>
        	<Pedido:NullBackgroundConverter x:Key="nullBackgroundConverter" Color="LightCoral" />
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" MaxHeight="70" />
            <RowDefinition Height="*" MaxHeight="70" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        
        <Label Content="Número:" VerticalAlignment="Center" />
        <TextBlock Text="{Binding Path=Numero}" Grid.Column="1" VerticalAlignment="Center" />
        
        <Label Content="Data:" VerticalAlignment="Center" Grid.Column="2" />
        <TextBlock Text="{Binding Path=Data,StringFormat=\{0:d/M/yyyy\}}" Grid.Column="3" VerticalAlignment="Center" />

        <Label Content="Cliente:" Grid.Row="1" VerticalAlignment="Center" />
        <ComboBox Background="{Binding Path=Cliente, Converter={StaticResource nullBackgroundConverter}}"
                  Grid.Row="1" Grid.Column="1" ItemsSource="{Binding Path=Clientes}" 
                  SelectedItem="{Binding Path=Cliente}" DisplayMemberPath="RazaoSocial" 
                  IsEnabled="{Binding Path=CanChangeCliente}" />
        
        <Label Content="Vendedor:" Grid.Row="1" Grid.Column="2" VerticalAlignment="Center" />
        <ComboBox Background="{Binding Path=Vendedor, Converter={StaticResource nullBackgroundConverter}}"
                  Grid.Row="1" Grid.Column="3" ItemsSource="{Binding Path=Vendedores}"
                  SelectedItem="{Binding Path=Vendedor}" DisplayMemberPath="Nome" />
        
        <Label Content="Transportadora:" Grid.Row="2" VerticalAlignment="Center" />
        <ComboBox Grid.Row="2" Grid.Column="1" VerticalAlignment="Center"
                  Background="{Binding Path=Transportadora, Converter={StaticResource nullBackgroundConverter}}"
                  ItemsSource="{Binding Path=Transportadoras}" SelectedItem="{Binding Path=Transportadora}"
                  DisplayMemberPath="Nome" IsEnabled="{Binding Path=CanChangeTransportadora}" />
        
        <Label Content="Fábrica:" Grid.Row="2" Grid.Column="2" VerticalAlignment="Center" />
        <ComboBox Background="{Binding Path=Fabrica, Converter={StaticResource nullBackgroundConverter}}"
                  Grid.Row="2" Grid.Column="3" ItemsSource="{Binding Path=Fabricas}" 
                  SelectedItem="{Binding Path=Fabrica}" DisplayMemberPath="Nome" />
        
        <Label Content="Condiçao de pagamento:" VerticalAlignment="Center" Grid.Row="3" />
        <TextBlock Text="{Binding Path=CondicaoPagamento}" Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" />
        
        <Label Content="Desconto:" VerticalAlignment="Center" Grid.Row="3" Grid.Column="2" />
        <TextBlock Text="{Binding Path=Desconto, StringFormat=\{0\}%}" Grid.Row="3" Grid.Column="3"
                   VerticalAlignment="Center" />

        <Label Content="Valor Desconto:" Grid.Row="4" VerticalAlignment="Center" />
        <TextBlock Text="{Binding Path=ValorDesconto, StringFormat=\{0:C\}}" Grid.Row="4" Grid.Column="1"
                   VerticalAlignment="Center" />
        
        <Label Content="Valor Imposto:" VerticalAlignment="Center" Grid.Row="4" Grid.Column="2" />
        <TextBlock Text="{Binding Path=ValorImposto, StringFormat=\{0:C\}}" Grid.Row="4" Grid.Column="3"
                   VerticalAlignment="Center" />

        <Label Content="Total Mercadoria:" Grid.Row="5" VerticalAlignment="Center" />
        <TextBlock Text="{Binding Path=TotalMercadoria, StringFormat=\{0:C\}}" Grid.Row="5" Grid.Column="1" 
                   VerticalAlignment="Center" />
        
        <Label Content="Total Líquido:" VerticalAlignment="Center" Grid.Row="5" Grid.Column="2" />
        <TextBlock Text="{Binding Path=TotalLiquido, StringFormat=\{0:C\}}" Grid.Row="5" Grid.Column="3"
                   VerticalAlignment="Center" />

        <Label Content="Observação:" Grid.Row="6" VerticalAlignment="Top" />
        <TextBox Text="{Binding Path=Observacao}" Grid.Row="6" Grid.Column="1" VerticalAlignment="Stretch" 
                 AcceptsReturn="True" AcceptsTab="True" VerticalScrollBarVisibility="Auto" TextWrapping="Wrap" />
        
        <Label Content="Prazo de entrega:" VerticalAlignment="Top" Grid.Row="6" Grid.Column="2" Margin="0,-5,0,0" />
        <TextBlock Text="{Binding Path=PrazoEntrega}" Grid.Row="6" Grid.Column="3" VerticalAlignment="Top" />

        <ContentControl Content="{Binding Path=AttributeList}" Grid.Row="7" Grid.ColumnSpan="4" />
        
        <Label Content="Produtos:" Grid.Row="8" VerticalAlignment="Top" Margin="0,5,0,0" />
        <ListView ItemsSource="{Binding Path=Produtos}" Grid.Row="8" Grid.Column="1" Grid.ColumnSpan="3" Margin="0,5,0,0"
                  VerticalAlignment="Stretch">
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Código" Width="150" DisplayMemberBinding="{Binding Path=Codigo}" />
                    <GridViewColumn Header="Descrição" Width="347" DisplayMemberBinding="{Binding Path=Descricao}" />
                    <GridViewColumn Header="Quantidade" Width="65" DisplayMemberBinding="{Binding Path=Quantidade}" />
                    <GridViewColumn Header="Preço Unitário" Width="90" 
                                    DisplayMemberBinding="{Binding Path=PrecoUnitario,StringFormat=\{0:C\}}" />
                    <GridViewColumn Header="Total" Width="95" 
                                    DisplayMemberBinding="{Binding Path=Total,StringFormat=\{0:C\}}" />
                </GridView>
            </ListView.View>
        </ListView>
    </Grid>
</UserControl>
